package com.im.service.common;

import cn.hutool.http.HttpStatus;
import lombok.Data;

/**
 * @author liuzhiqiang
 */
@Data
public class Result<T> {

    private Integer code;

    private String msg;

    private T data;


    public static Result ok() {
        Result result = new Result();
        result.setCode(HttpStatus.HTTP_OK);
        result.setMsg("success");
        return result;
    }

    public static <T> Result<T> okData(T data) {
        Result result = ok();
        result.setData(data);
        return result;
    }


    public static Result error() {
        Result result = new Result();
        result.setCode(HttpStatus.HTTP_INTERNAL_ERROR);
        return result;
    }

    public static Result error(String msg) {
        Result result = error();
        result.setMsg(msg);
        return result;
    }

    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }


}
